﻿using Microsoft.Extensions.Logging;
using RBAC.MaHaiBo.Entity;
using RBAC.MaHaiBo.Repository.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RBAC.MaHaiBo.Service
{
    public class ProvinceService : IProvinceService
    {
        /// <summary>
        /// 日志
        /// </summary>
        ILogger<ProvinceService> logger;
        /// <summary>
        /// 省仓储
        /// </summary>
        IProvinceRepository pRep;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="logger">日志</param>
        /// <param name="pRep">省仓储</param>
        public ProvinceService(ILogger<ProvinceService> logger,
         IProvinceRepository pRep
         )
        {
            this.logger = logger;
            this.pRep = pRep;
        }

        /// <summary>
        /// 省
        /// </summary>
        /// <returns>返回省信息列表</returns>
        public Task<List<Province>> GetProvince()
        {
            try
            {
                return pRep.GetAllAsync();
            }
            catch (Exception ex)
            {
                logger.LogError("【省服务层】 省信息列表" + ex.Message);
                throw;
            }
        }

    }
}
